<?php

namespace app\data\controller;
use think\admin\Controller;
use think\admin\helper\QueryHelper;
use app\data\model\DataCat;
use app\data\model\DataCatWeightLog;
/**
 * 宠物管理
 * @class Member
 * @package app\data\controller
 */
class Cat extends Controller
{
    /**
     * 宠物管理
     * @menu true
     * @auth true
     */
    public function index()
    {
        DataCat::mQuery()->layTable(function () {
            $this->title = '宠物管理';
        }, function (QueryHelper $query) {
            $query->alias('c')->field('c.*,m.nickname as m_nickname,m.mobile,g.gender_name,b.breed_name');
            $query->join('data_member m','m.id = c.member_id');
            $query->join('data_gender g','g.id = c.gender');
            $query->join('data_breed b','b.id = c.breed');
            $query->where(['c.is_deleted' => 0]);
            // 数据列表搜索过滤
            $query->dateBetween('c.create_at#create_at');
            $query->like('cat_name,nickname,mobile')->order('c.sort desc,id asc');
        });
    }
    /**
     * 如厕日志查询
     * @auth true
     */
    public function toilet_select(){
        $id =input('param.id/d');
        $query = $this->_query('data_cat_log');
        $query->dateBetween('create_at');
        $query->where('cat_id','=',$id)->order('create_at desc')->page();
    }

}
